import requests
import json


def search_music(music_name):
    url = f'https://v1.alapi.cn/api/music/search?keyword={music_name}'
    r = requests.get(url=url)
    if r.status_code != 200:
        exit(1)
    print(r.encoding)
    music_list = json.loads(r.content.decode('utf-8'))['data']['songs']
    return music_list


if __name__ == '__main__':
    search_music('湖')
